/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ApproverTaskFrame.java
 *
 * Created on 22 Mei 13, 21:01:45
 */
package com.ivanbiz.gui;

import com.ivanbiz.dao.InternalDeliveryDAO;
import com.ivanbiz.dao.InternalDeliveryItemDAO;
import com.ivanbiz.dao.ItemDAO;
import com.ivanbiz.dao.PurchaseOrderDAO;
import com.ivanbiz.dao.PurchaseOrderItemDAO;
import com.ivanbiz.dao.impl.InternalDeliveryDAOImpl;
import com.ivanbiz.dao.impl.InternalDeliveryItemDAOImpl;
import com.ivanbiz.dao.impl.ItemDAOImpl;
import com.ivanbiz.dao.impl.PurchaseOrderDAOImpl;
import com.ivanbiz.dao.impl.PurchaseOrderItemDAOImpl;
import com.ivanbiz.helper.GlobalConstant;
import com.ivanbiz.helper.GlobalSession;
import com.ivanbiz.helper.ServiceHelper;
import com.ivanbiz.helper.UserSession;
import com.ivanbiz.injection.CallCtx;
import com.ivanbiz.model.InternalDelivery;
import com.ivanbiz.model.InternalDeliveryItem;
import com.ivanbiz.model.Item;
import com.ivanbiz.model.PurchaseOrder;
import com.ivanbiz.model.PurchaseOrderItem;
import com.ivanbiz.model.User;
import com.ivanbiz.remote.GlobalService;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 *
 * @author Shbt Peterpan
 */
public class ApproverTaskFrame extends javax.swing.JInternalFrame {

    List<PurchaseOrderItem> listPurchaseOrderItem = new ArrayList<PurchaseOrderItem>();
    List<PurchaseOrder> listPurchaseOrder = new ArrayList<PurchaseOrder>();
    List<InternalDeliveryItem> listInternalDeliveryItem = new ArrayList<InternalDeliveryItem>();
    List<InternalDelivery> listInternalDelivery = new ArrayList<InternalDelivery>();
    List<Item> listItem = new ArrayList<Item>();
    ItemDAO itemDAO = new ItemDAOImpl();
    InternalDeliveryDAO internalDeliveryDAO = new InternalDeliveryDAOImpl();
    InternalDeliveryItemDAO internalDeliveryItemDAO = new InternalDeliveryItemDAOImpl();
    PurchaseOrderItemDAO purchaseOrderItemDAO = new PurchaseOrderItemDAOImpl();
    PurchaseOrderDAO purchaseOrderDAO = new PurchaseOrderDAOImpl();
    ServiceHelper serviceHelper = new ServiceHelper();
    NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
    User user = UserSession.getUser();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy");

    /** Creates new form ApproverTaskFrame */
    public ApproverTaskFrame() {
        initComponents();
        setVisible(true);
        updateData();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dialogTask = new javax.swing.JDialog();
        jPanel10 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tableDataTask = new javax.swing.JTable();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tableData = new javax.swing.JTable();
        jPanel6 = new javax.swing.JPanel();
        buttonReject = new javax.swing.JButton();
        buttonApprove = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        comboSearch = new javax.swing.JComboBox();
        textSearch = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        comboSearch1 = new javax.swing.JComboBox();
        textSearch1 = new javax.swing.JTextField();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tableData1 = new javax.swing.JTable();
        jPanel9 = new javax.swing.JPanel();
        buttonReject1 = new javax.swing.JButton();
        buttonApprove1 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        comboSearch2 = new javax.swing.JComboBox();
        textSearch2 = new javax.swing.JTextField();
        jPanel12 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tableData2 = new javax.swing.JTable();
        jPanel13 = new javax.swing.JPanel();
        buttonReject2 = new javax.swing.JButton();
        buttonApprove2 = new javax.swing.JButton();

        dialogTask.setModal(true);

        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Table Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        tableDataTask.setAutoCreateRowSorter(true);
        tableDataTask.setFont(new java.awt.Font("Monospaced", 1, 14));
        tableDataTask.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tableDataTask.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableDataTaskMouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(tableDataTask);

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout dialogTaskLayout = new javax.swing.GroupLayout(dialogTask.getContentPane());
        dialogTask.getContentPane().setLayout(dialogTaskLayout);
        dialogTaskLayout.setHorizontalGroup(
            dialogTaskLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogTaskLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        dialogTaskLayout.setVerticalGroup(
            dialogTaskLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogTaskLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.setFont(new java.awt.Font("Monospaced", 1, 14));

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Table Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        tableData.setAutoCreateRowSorter(true);
        tableData.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        tableData.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tableData.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableDataMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tableData);

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 617, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Button", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        buttonReject.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        buttonReject.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/cancel.jpg"))); // NOI18N
        buttonReject.setText("Reject");
        buttonReject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonRejectActionPerformed(evt);
            }
        });

        buttonApprove.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        buttonApprove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Aprove.jpg"))); // NOI18N
        buttonApprove.setText("Approve");
        buttonApprove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonApproveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(buttonApprove)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonReject, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonReject, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonApprove, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        comboSearch.setFont(new java.awt.Font("Monospaced", 1, 14));

        textSearch.setFont(new java.awt.Font("Monospaced", 1, 14));
        textSearch.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textSearchKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(comboSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textSearch, javax.swing.GroupLayout.DEFAULT_SIZE, 447, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Purchase Order Task", jPanel1);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        comboSearch1.setFont(new java.awt.Font("Monospaced", 1, 14));

        textSearch1.setFont(new java.awt.Font("Monospaced", 1, 14));
        textSearch1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textSearch1KeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(comboSearch1, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textSearch1, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textSearch1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboSearch1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Table Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        tableData1.setAutoCreateRowSorter(true);
        tableData1.setFont(new java.awt.Font("Monospaced", 1, 14));
        tableData1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tableData1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableData1MouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tableData1);

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 617, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Button", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        buttonReject1.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonReject1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/cancel.jpg"))); // NOI18N
        buttonReject1.setText("Reject");
        buttonReject1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonReject1ActionPerformed(evt);
            }
        });

        buttonApprove1.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonApprove1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Aprove.jpg"))); // NOI18N
        buttonApprove1.setText("Approve");
        buttonApprove1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonApprove1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buttonApprove1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(buttonReject1, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonReject1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonApprove1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Internal Delivery Task", jPanel2);

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        comboSearch2.setFont(new java.awt.Font("Monospaced", 1, 14));

        textSearch2.setFont(new java.awt.Font("Monospaced", 1, 14));
        textSearch2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textSearch2KeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(comboSearch2, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textSearch2, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textSearch2, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboSearch2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Table Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        tableData2.setAutoCreateRowSorter(true);
        tableData2.setFont(new java.awt.Font("Monospaced", 1, 14));
        tableData2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane5.setViewportView(tableData2);

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 617, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Button", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        buttonReject2.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonReject2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/cancel.jpg"))); // NOI18N
        buttonReject2.setText("Reject");
        buttonReject2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonReject2ActionPerformed(evt);
            }
        });

        buttonApprove2.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonApprove2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Aprove.jpg"))); // NOI18N
        buttonApprove2.setText("Approve");
        buttonApprove2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonApprove2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buttonApprove2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(buttonReject2, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonReject2, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonApprove2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel12, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel13, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Item Task", jPanel3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 674, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buttonRejectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRejectActionPerformed
        try {
            int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.YES_OPTION) {
                for (int x = 0; x < listPurchaseOrder.size(); x++) {
                    PurchaseOrder purchaseOrder = listPurchaseOrder.get(x);
                    if ((Boolean) tableData.getValueAt(x, 0)) {
                        purchaseOrder.setStatus(GlobalConstant.R);
                        purchaseOrder.setApprovedDate(new Date());
                        purchaseOrder.setApprovedBy(user.getUserName());
                        purchaseOrderDAO.update(purchaseOrder);
                    }
                }
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_REJECT);
                updateData();
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
            Logger.getLogger(ApproverTaskFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_buttonRejectActionPerformed

    private void buttonApproveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApproveActionPerformed
        try {
            int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.YES_OPTION) {
                for (int x = 0; x < listPurchaseOrder.size(); x++) {
                    PurchaseOrder purchaseOrder = listPurchaseOrder.get(x);
                    if ((Boolean) tableData.getValueAt(x, 0)) {
                        purchaseOrder.setApprovedDate(new Date());
                        purchaseOrder.setApprovedBy(user.getUserName());
                        purchaseOrderDAO.approvePurchaseOrder(purchaseOrder);
                    }
                }
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_APR);
                updateData();
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
            Logger.getLogger(ApproverTaskFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_buttonApproveActionPerformed

    private void textSearchKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textSearchKeyReleased
        try {
            listPurchaseOrder = purchaseOrderDAO.getDataByLike((String) comboSearch.getSelectedItem(), textSearch.getText(), "status", GlobalConstant.N);
            updateTablePO();
        } catch (Exception ex) {
            Logger.getLogger(ApproverTaskFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_textSearchKeyReleased

    private void textSearch1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textSearch1KeyReleased
        try {
            listInternalDelivery = internalDeliveryDAO.getDataByLike((String) comboSearch1.getSelectedItem(), textSearch1.getText(), "status", GlobalConstant.N);
            updateTableID();
        } catch (Exception ex) {
            Logger.getLogger(ApproverTaskFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_textSearch1KeyReleased

    private void buttonReject1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReject1ActionPerformed
        try {
            int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.YES_OPTION) {
                for (int x = 0; x < listInternalDelivery.size(); x++) {
                    InternalDelivery internalDelivery = listInternalDelivery.get(x);
                    if ((Boolean) tableData1.getValueAt(x, 0)) {
                        internalDelivery.setStatus(GlobalConstant.R);
                        internalDelivery.setApprovedBy(user.getUserName());
                        internalDelivery.setApprovedDate(new Date());
                        internalDeliveryDAO.update(internalDelivery);
                    }
                }
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_REJECT);
                updateData();
            }
        } catch (Exception ex) {
            Logger.getLogger(ApproverTaskFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_buttonReject1ActionPerformed

    private void buttonApprove1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApprove1ActionPerformed
        String status = GlobalConstant.EMPTY_STRING;
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            for (int x = 0; x
                    < listInternalDelivery.size(); x++) {
                InternalDelivery internalDelivery = listInternalDelivery.get(x);
                if ((Boolean) tableData1.getValueAt(x, 0)) {
                    try {
                        GlobalService globalService = (GlobalService) CallCtx.getBean("invokeRatuAyu");
                        status = globalService.sendInternalDelivery(internalDelivery.getNomorInternalDelivery(), internalDelivery.getCabang().getKode());
                        if (status.equals(GlobalConstant.Y)) {
                            internalDelivery.setStatus(GlobalConstant.N);
                            internalDelivery.setApprovedBy(user.getUserName());
                            internalDelivery.setApprovedDate(new Date());
                            internalDeliveryDAO.update(internalDelivery);
                        }
                    } catch (Exception ex) {
                        JOptionPane.showMessageDialog(null, ex.getMessage());
                        Logger.getLogger(ApproverTaskFrame.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
            if (status.equals(GlobalConstant.Y)) {
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_APR);
                updateData();
            } else if (status.equals(GlobalConstant.N) || status.equals(GlobalConstant.EMPTY_STRING)) {
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_NOT_SUCCESS);
            }
        }
    }//GEN-LAST:event_buttonApprove1ActionPerformed

    private void tableDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableDataMouseClicked
        try {
            if (evt.getClickCount() == 2) {
                listPurchaseOrderItem = purchaseOrderItemDAO.getDataByEquals(PurchaseOrderItem.class, "nomerPO", (String) tableData.getValueAt(tableData.getSelectedRow(), 2));
                updateTablePOI();
                dialogTask.setSize(GlobalSession.getDesktopsize());
                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                Dimension frameSize = dialogTask.getSize();
                dialogTask.setLocation(
                        (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
                dialogTask.setVisible(
                        true);
            }
        } catch (Exception ex) {
            Logger.getLogger(ApproverTaskFrame.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_tableDataMouseClicked

    private void tableData1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableData1MouseClicked
        if (evt.getClickCount() == 2) {
            try {
                listInternalDeliveryItem = internalDeliveryItemDAO.getDataByEquals(InternalDeliveryItem.class, "nomorInternalDelivery", (String) tableData1.getValueAt(tableData1.getSelectedRow(), 2));
                updateTableIDI();
                dialogTask.setSize(GlobalSession.getDesktopsize());
                Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                Dimension frameSize = dialogTask.getSize();
                dialogTask.setLocation(
                        (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
                dialogTask.setVisible(
                        true);
            } catch (Exception ex) {
                Logger.getLogger(ApproverTaskFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_tableData1MouseClicked

    private void tableDataTaskMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableDataTaskMouseClicked
}//GEN-LAST:event_tableDataTaskMouseClicked

    private void textSearch2KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textSearch2KeyReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_textSearch2KeyReleased

    private void buttonReject2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReject2ActionPerformed
        try {
            int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.YES_OPTION) {
                for (int x = 0; x < listItem.size(); x++) {
                    Item item = listItem.get(x);
                    if ((Boolean) tableData2.getValueAt(x, 0)) {
                        item.setStatus(GlobalConstant.R);
                        item.setApprovedDate(new Date());
                        item.setApprovedBy(user.getUserName());
                        itemDAO.update(item);
                    }
                }
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_REJECT);
                updateData();
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
            Logger.getLogger(ApproverTaskFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_buttonReject2ActionPerformed

    private void buttonApprove2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApprove2ActionPerformed
        try {
            int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.YES_OPTION) {
                for (int x = 0; x < listItem.size(); x++) {
                    Item item = listItem.get(x);
                    if ((Boolean) tableData2.getValueAt(x, 0)) {
                        item.setStatus(GlobalConstant.Y);
                        item.setApprovedDate(new Date());
                        item.setApprovedBy(user.getUserName());
                        itemDAO.update(item);
                    }
                }
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_APR);
                updateData();
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
            Logger.getLogger(ApproverTaskFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_buttonApprove2ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonApprove;
    private javax.swing.JButton buttonApprove1;
    private javax.swing.JButton buttonApprove2;
    private javax.swing.JButton buttonReject;
    private javax.swing.JButton buttonReject1;
    private javax.swing.JButton buttonReject2;
    private javax.swing.JComboBox comboSearch;
    private javax.swing.JComboBox comboSearch1;
    private javax.swing.JComboBox comboSearch2;
    private javax.swing.JDialog dialogTask;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable tableData;
    private javax.swing.JTable tableData1;
    private javax.swing.JTable tableData2;
    private javax.swing.JTable tableDataTask;
    private javax.swing.JTextField textSearch;
    private javax.swing.JTextField textSearch1;
    private javax.swing.JTextField textSearch2;
    // End of variables declaration//GEN-END:variables

    private void updateData() {
        try {
            listPurchaseOrder = purchaseOrderDAO.getDataByEquals(PurchaseOrder.class, "status", GlobalConstant.N);
            listInternalDelivery = internalDeliveryDAO.getDataByEquals(InternalDelivery.class, "status", GlobalConstant.N);
            listItem = itemDAO.getDataByEquals(Item.class, "status", GlobalConstant.N);
            clearTable();
            updateTablePO();
            updateTableID();
            updateTableItem();
            updateComboCariPO();
            updateComboCariID();
        } catch (Exception ex) {
            Logger.getLogger(ApproverTaskFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void clearTable() {
        textSearch.setText(GlobalConstant.EMPTY_STRING);
        textSearch1.setText(GlobalConstant.EMPTY_STRING);
        jPanel4.setVisible(false);
        jPanel5.setVisible(false);
        jPanel11.setVisible(false);
    }

    private void updateTablePOI() {
        String[] judul = {GlobalConstant.NO, GlobalConstant.NO_PO, GlobalConstant.KODE_BARCODE, GlobalConstant.NAMA, GlobalConstant.QUANTITY, GlobalConstant.HARGA_MODAL, GlobalConstant.DISKON, GlobalConstant.DISKON, GlobalConstant.DISKON, GlobalConstant.DISKON, GlobalConstant.TOTAL, GlobalConstant.DESCRIPTION};
        Object[][] isi = null;
        isi = new Object[listPurchaseOrderItem.size()][12];
        int x = 0;
        int no = 0;
        for (PurchaseOrderItem purchaseOrderItem : listPurchaseOrderItem) {
            isi[x][0] = no += 1;
            isi[x][1] = purchaseOrderItem.getNomerPO();
            isi[x][2] = purchaseOrderItem.getKodeBarcode();
            isi[x][3] = purchaseOrderItem.getNamaItem();
            isi[x][4] = purchaseOrderItem.getQuantity();
            isi[x][5] = numberFormat.format(purchaseOrderItem.getHargaModal());
            isi[x][6] = purchaseOrderItem.getDiskon1();
            isi[x][7] = purchaseOrderItem.getDiskon2();
            isi[x][8] = purchaseOrderItem.getDiskon3();
            isi[x][9] = purchaseOrderItem.getDiskon4();
            isi[x][10] = numberFormat.format(purchaseOrderItem.getSubTotal());
            isi[x][11] = purchaseOrderItem.getDescription();
            x++;
        }
        tableDataTask.setModel(new DefaultTableModel(isi, judul) {

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                if (columnIdentifiers.get(columnIndex).equals(GlobalConstant.CHOOSE)) {
                    return true;
                } else {
                    return false;
                }
            }

            @Override
            public Class getColumnClass(int columnIndex) {
                if (columnIdentifiers.get(columnIndex).equals(GlobalConstant.CHOOSE)) {
                    return Boolean.class;
                } else {
                    return columnIdentifiers.get(columnIndex).getClass();
                }
            }
        });

        TableColumn column0 = tableDataTask.getColumnModel().getColumn(0);
        column0.setPreferredWidth(75);
        column0.setMaxWidth(75);
    }

    private void updateTablePO() {
        String[] judul = {GlobalConstant.CHOOSE, GlobalConstant.NO, GlobalConstant.NO_PO, GlobalConstant.SUPPLIER, "Tanggal PO", "Total", "Pembayaran", "Jatuh Tempo"};
        Object[][] isi = null;
        isi = new Object[listPurchaseOrder.size()][8];
        int x = 0;
        int no = 0;
        for (PurchaseOrder purchaseOrder : listPurchaseOrder) {
            isi[x][0] = purchaseOrder.isCheck();
            isi[x][1] = no += 1;
            isi[x][2] = purchaseOrder.getNomerPO();
            isi[x][3] = purchaseOrder.getSupplier().getNama();
            isi[x][4] = purchaseOrder.getTanggalPO();
            isi[x][5] = purchaseOrder.getTotal() == null ? purchaseOrder.getTotal() : numberFormat.format(purchaseOrder.getTotal());
            isi[x][6] = purchaseOrder.getPembayaran();
            isi[x][7] = purchaseOrder.getJatuhTempo() == null ? purchaseOrder.getJatuhTempo() : simpleDateFormat.format(purchaseOrder.getJatuhTempo());
            x++;
        }
        tableData.setModel(new DefaultTableModel(isi, judul) {

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                if (columnIdentifiers.get(columnIndex).equals(GlobalConstant.CHOOSE)) {
                    return true;
                } else {
                    return false;
                }
            }

            @Override
            public Class getColumnClass(int columnIndex) {
                if (columnIdentifiers.get(columnIndex).equals(GlobalConstant.CHOOSE)) {
                    return Boolean.class;
                } else {
                    return columnIdentifiers.get(columnIndex).getClass();
                }
            }
        });

        TableColumn column0 = tableData.getColumnModel().getColumn(0);
        column0.setPreferredWidth(60);
        column0.setMaxWidth(60);
        TableColumn column1 = tableData.getColumnModel().getColumn(1);
        column1.setPreferredWidth(75);
        column1.setMaxWidth(75);
    }

    private void updateComboCariPO() {
        Object[] dataClass = serviceHelper.getPropertyClass(PurchaseOrderItem.class);
        Object[] dataSearch = new Object[1];
        dataSearch[0] = dataClass[11];
        comboSearch.setModel(
                new DefaultComboBoxModel(dataSearch));
    }

    private void updateTableIDI() {
        String[] judul = {GlobalConstant.NO, GlobalConstant.NO_ID, GlobalConstant.KODE_BARCODE, GlobalConstant.NAMA, GlobalConstant.HARGA_MODAL, GlobalConstant.QUANTITY, GlobalConstant.DATE_RECEIVE};
        Object[][] isi = new Object[listInternalDeliveryItem.size()][7];
        int x = 0;
        int no = 0;
        for (InternalDeliveryItem internalDeliveryItem : listInternalDeliveryItem) {
            isi[x][0] = no += 1;
            isi[x][1] = internalDeliveryItem.getNomorInternalDelivery();
            isi[x][2] = internalDeliveryItem.getKodeBarcode();
            isi[x][3] = internalDeliveryItem.getNamaItem();
            isi[x][4] = numberFormat.format(internalDeliveryItem.getHargaModal());
            isi[x][5] = internalDeliveryItem.getQuantity();
            isi[x][6] = internalDeliveryItem.getDateReceive();
            x++;
        }
        tableDataTask.setModel(new DefaultTableModel(isi, judul) {

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                if (columnIdentifiers.get(columnIndex).equals(GlobalConstant.CHOOSE)) {
                    return true;
                } else {
                    return false;
                }
            }

            @Override
            public Class getColumnClass(int columnIndex) {
                if (columnIdentifiers.get(columnIndex).equals(GlobalConstant.CHOOSE)) {
                    return Boolean.class;
                } else {
                    return columnIdentifiers.get(columnIndex).getClass();
                }
            }
        });

        TableColumn column0 = tableDataTask.getColumnModel().getColumn(0);
        column0.setPreferredWidth(75);
        column0.setMaxWidth(75);
        TableColumn column1 = tableDataTask.getColumnModel().getColumn(1);
        column1.setPreferredWidth(75);
        column1.setMaxWidth(75);
    }

    private void updateTableID() {
        String[] judul = {GlobalConstant.CHOOSE, GlobalConstant.NO, GlobalConstant.NO_ID, GlobalConstant.CABANG, "Tanggal Kirim"};
        Object[][] isi = new Object[listInternalDelivery.size()][5];
        int x = 0;
        int no = 0;
        for (InternalDelivery internalDelivery : listInternalDelivery) {
            isi[x][0] = internalDelivery.isCheck();
            isi[x][1] = no += 1;
            isi[x][2] = internalDelivery.getNomorInternalDelivery();
            isi[x][3] = internalDelivery.getCabang().getKode();
            isi[x][4] = internalDelivery.getTanggalKirim();
            x++;
        }
        tableData1.setModel(new DefaultTableModel(isi, judul) {

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                if (columnIdentifiers.get(columnIndex).equals(GlobalConstant.CHOOSE)) {
                    return true;
                } else {
                    return false;
                }
            }

            @Override
            public Class getColumnClass(int columnIndex) {
                if (columnIdentifiers.get(columnIndex).equals(GlobalConstant.CHOOSE)) {
                    return Boolean.class;
                } else {
                    return columnIdentifiers.get(columnIndex).getClass();
                }
            }
        });

        TableColumn column0 = tableData1.getColumnModel().getColumn(0);
        column0.setPreferredWidth(60);
        column0.setMaxWidth(60);
        TableColumn column1 = tableData1.getColumnModel().getColumn(1);
        column1.setPreferredWidth(75);
        column1.setMaxWidth(75);
    }

    private void updateComboCariID() {
        Object[] dataClass = serviceHelper.getPropertyClass(InternalDeliveryItem.class);
        Object[] dataSearch = new Object[1];
        dataSearch[0] = dataClass[6];
        comboSearch1.setModel(
                new DefaultComboBoxModel(dataSearch));
    }

    private void updateTableItem() {
        String[] judul = {GlobalConstant.CHOOSE, GlobalConstant.NO, GlobalConstant.KODE_BARCODE, GlobalConstant.NAMA, GlobalConstant.DESCRIPTION};
        Object[][] isi = new Object[listItem.size()][5];
        int x = 0;
        int no = 0;
        for (Item item : listItem) {
            isi[x][0] = item.isCheck();
            isi[x][1] = no += 1;
            isi[x][2] = item.getKodeBarcode();
            isi[x][3] = item.getNamaItem();
            isi[x][4] = item.getDescription();
            x++;
        }
        tableData2.setModel(new DefaultTableModel(isi, judul) {

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                if (columnIdentifiers.get(columnIndex).equals(GlobalConstant.CHOOSE)) {
                    return true;
                } else {
                    return false;
                }
            }

            @Override
            public Class getColumnClass(int columnIndex) {
                if (columnIdentifiers.get(columnIndex).equals(GlobalConstant.CHOOSE)) {
                    return Boolean.class;
                } else {
                    return columnIdentifiers.get(columnIndex).getClass();
                }
            }
        });

        TableColumn column0 = tableData2.getColumnModel().getColumn(0);
        column0.setPreferredWidth(60);
        column0.setMaxWidth(60);
        TableColumn column1 = tableData2.getColumnModel().getColumn(1);
        column1.setPreferredWidth(75);
        column1.setMaxWidth(75);
        TableColumn column2 = tableData2.getColumnModel().getColumn(2);
        column2.setPreferredWidth(150);
        column2.setMaxWidth(150);

    }
}
